/*
 *  $Id: WoodlandDefender.cs 1051 2010-05-18 22:10:41Z thenn.erannor $
 *  This file is a part of Ragima CCG.
 *  (C) 2008 Ragima development group.
 *
 *  Licensed under the terms of the GNU GPL License version 2.
 *
 */

namespace Ragima.Cards001.Earth.Creatures {
    public class WoodlandDefender: CreatureCard {
        public WoodlandDefender(): base("001_e_c_woodland_defender") {
            Level = CompleteLevel.ReadyForTest;
            Element = ElementType.Earth;
            Value = 100;
            Damage = 4;
            Health = 8;
            AddManaCost(ElementType.Earth, 6);
        }
        public override void SetAbilities(ICollector<AbilityCard> abilities) {
            abilities.Add<Abilities.BackToBack>();
        }
        public override void SetNaturalAffects(ICollector<Affect> affects) {
            affects.Add<Affects.Guardian>();
            affects.Add(new Affects.Immune(DamageType.Fire));
            affects.Add(new Affects.Immune(DamageType.Wound));
            affects.Add<WoodlandDefenderGrowth>();
        }

        private class WoodlandDefenderGrowth: Affect {
            public override string Id {
                get { return AffectManager.GetCardId<WoodlandDefender>("growth"); }
            }

            public override void SetAffect() {
                base.SetAffect();
                GlobalSummary.OnLandSummon += DoGrowth;
            }
            public override void ResetAffect() {
                base.SetAffect();
                GlobalSummary.OnLandSummon -= DoGrowth;
            }

            private void DoGrowth(Land land) {
                if (land.Card.Element == ElementType.Earth) {
                    LocalSummary.ChangeMaxHealth(1);
                    LocalSummary.ChangeDamage(1);
                }
            }
        }
    }
}
